package dnl.persistence;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class StandaloneJdbcUtil {

	private BasicDataSource dataSource;
	
	public StandaloneJdbcUtil() {
		this.dataSource = new BasicDataSource();
	}

	public String getDriverClassName() {
		return dataSource.getDriverClassName();
	}

	public String getPassword() {
		return dataSource.getPassword();
	}

	public String getUrl() {
		return dataSource.getUrl();
	}

	public String getUsername() {
		return dataSource.getUsername();
	}

	public DataSource getDataSource() {
		return dataSource;
	}

	public JdbcTemplate getJdbcTemplate() {
		return new JdbcTemplate(getDataSource());
	}

	public Connection getConnection() throws SQLException {
		return dataSource.getConnection();
	}

	public void setDefaultAutoCommit(boolean defaultAutoCommit) {
		dataSource.setDefaultAutoCommit(defaultAutoCommit);
	}

	public void setDefaultReadOnly(boolean defaultReadOnly) {
		dataSource.setDefaultReadOnly(defaultReadOnly);
	}

	public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
	}

	public void setDriverClassName(String driverClassName) {
		dataSource.setDriverClassName(driverClassName);
	}

	public void setPassword(String password) {
		dataSource.setPassword(password);
	}

	public void setUrl(String url) {
		dataSource.setUrl(url);
	}

	public void setUsername(String username) {
		dataSource.setUsername(username);
	}

	public void setValidationQuery(String validationQuery) {
		dataSource.setValidationQuery(validationQuery);
	}

}
